package com.itheima.controller.subject;

import com.itheima.api.subject.CmsSubjectService;
import com.itheima.vo.domain.AjaxResult;
import com.itheima.vo.pojo.CmsSubject;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/subject")
@Slf4j
public class CmsSubjectController {

    @DubboReference
    private CmsSubjectService subjectService;

    /**
     * 根据专题名称分页获取商品专题
     * @param pageNum
     * @param pageSize
     * @param keyword
     * @return
     */
    @GetMapping("/list")
    public AjaxResult list(Integer pageNum,Integer pageSize,String keyword){
      Map map =  subjectService.findPage(pageNum,pageSize,keyword);
        return AjaxResult.success(map);
    }

    /**
     * 获取全部商品专题
     * @return
     */
    @GetMapping("/listAll")
    public AjaxResult listAll(){
        List<CmsSubject> list = subjectService.list();
        return AjaxResult.success(list);
    }
}
